home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / cardpkg_1.3.lha / CardPkg / trimline.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-19  |  769 b   |  35 lines

  1. /*
  2.  *  TrimLine.c cuts program source text into reasonable line lengths.
  3.  *  This has been a problem with some sources which are generated by
  4.  *  programs--ILBM2Image for example.
  5.  *  Standard input and standard output are used.
  6.  */
  7.  
  8. #include <stdio.h>
  9.  
  10. int main(int argc, char *argv[])
  11.   {
  12.     int a, column;
  13.  
  14.     column = 0;
  15.  
  16.     while( (a=getchar()) != EOF)
  17.       {
  18.         putchar(a);
  19.         column++;
  20.         switch (a)
  21.           {
  22.             case ',' :
  23.             case ' ' : if (column > 60)
  24.                          {
  25.                            putchar('\n');
  26.                            column = 0;
  27.                          }
  28.                        break;
  29.             case '\n': column = 0;
  30.             default  : break;
  31.           }
  32.       }
  33.     return 0;
  34.   }
  35.